package io.github.tuuzed.hydrogen;

import java.util.List;

public class Select {
    private String[] mColumns;
    private boolean isDistinct;


    public Select distinct() {
        isDistinct = true;
        return this;
    }

    public Select() {
    }

    public Select(String[] columns) {
        mColumns = columns;
    }

    public From from(Class<? extends Model> clazz) {
        if (mColumns == null) {
            List<Hydrogen.ColumnInfo> columnInfoList = Hydrogen.getInstance().getColumnInfoList(clazz);
            mColumns = new String[columnInfoList.size() + 1];
            mColumns[0] = "_id";
            for (int i = 0; i < columnInfoList.size(); i++) {
                mColumns[i + 1] = columnInfoList.get(i).getColumnName();
            }
        }
        return new From(clazz, isDistinct, mColumns);
    }
}
